@extends('layouts.app', ['activePage' => 'competition', 'titlePage' => __('比赛管理')])

@section('content')
  <div class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-12">
          <form method="post" action="{{route('competitions.update',$competition->id)}}" autocomplete="off" class="form-horizontal">
            @csrf
            @method('patch')
            <div class="card ">
                <div class="card-header card-header-primary">
                    <h4 class="card-title">编辑比赛</h4>
                    <p class="card-category">编辑未发布或已下架的比赛</p>
                </div>
                <div class="card-body ">
                    <div class="row">
                        <div class="col-md-12 text-right">
                            <a href="/competitions" class="btn btn-sm btn-primary">返回比赛列表</a>
                        </div>
                      </div>
                    <div class="form-group">
                        <label for="title">主题</label>
                        <input type="text" class="form-control" id="title" placeholder="请输入比赛标题" required name="title" value="{{old('title')? old('title'):$competition->title}}">
                        @if ($errors->has('title'))
                          <span id="name-error" class="error text-danger" for="title">至少输入6位字符</span>
                        @endif
                      </div>
                    <div class="form-group">
                        <label for="description">描述</label>
                        <input type="text" class="form-control" id="description" placeholder="在此输入比赛内容及描述" required name="description" value="{{old('description')? old('description'):$competition->description}}">
                        @if ($errors->has('description'))
                          <span id="name-error" class="error text-danger" for="description">至少输入4位字符</span>
                        @endif
                    </div>

                    <div class="form-group">
                      <label for="location">地点</label>
                      <input type="text" class="form-control" id="location" placeholder="在此输入比赛举办的地点" name="location" required value="{{old('location')? old('location'):$competition->location}}">
                      @if ($errors->has('location'))
                        <span id="name-error" class="error text-danger" for="location">至少输入3位字符</span>
                      @endif
                    </div>
                    <div class="form-row">
                      <div class="form-group col-md-4">
                          <label class="label-control">报名截止时间</label>
                          <input type="datetime-local" class="form-control datetimepicker" step="01" min="{{$time->get('now')}}" name="deadline"  required value="{{$time->get('deadline')}}"/>
                          @if ($errors->has('deadline'))
                          <span id="name-error" class="error text-danger" for="deadline">输入日期应在明天以后</span>
                        @endif
                        </div>
                      <div class="form-group col-md-4">
                          <label class="label-control">比赛开始时间</label>
                          <input type="datetime-local" class="form-control datetimepicker" step="01" min="{{$time->get('now')}}" name="start_time" required value="{{$time->get('start_time')}}"/>
                          @if ($errors->has('start_time'))
                            <span id="name-error" class="error text-danger" for="start_time">输入日期应晚于报名截止时间</span>
                          @endif
                        </div>
                      <div class="form-group col-md-4">
                          <label class="label-control">比赛结束时间</label>
                          <input type="datetime-local" class="form-control datetimepicker" step="01" min="{{$time->get('now')}}" name="end_time"  required value="{{$time->get('end_time')}}"/>
                          @if ($errors->has('end_time'))
                            <span id="name-error" class="error text-danger" for="end_time">输入日期应晚于比赛开始时间</span>
                          @endif
                        </div>
                  </div>

                </div>
                <div class="card-footer ml-auto mr-auto">
                    <button type="submit" class="btn btn-primary">保存</button>
                </div>
            </div>

          </form>
        </div>
      </div>
    </div>
  </div>
@endsection
